Use Database::addQuotes in Special:WantedPages/UnwatchedPages
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 29 Oct 2016 18:50:57 +0000 (20:50 +0200)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 2 Nov 2016 23:24:40 +0000 (23:24 +0000)
Database::addQuotes uses the correct quotes/apos, hopefully together
with numeric values

Change-Id: Ia3aba8cabf3ae877f56185e5724dca204a19f73a

includes/specials/SpecialUnwatchedpages.php
includes/specials/SpecialWantedpages.php

index df57744..a4e96ae 100644 (file)
@@ -44,6 +44,7 @@ class UnwatchedpagesPage extends QueryPage {
        }
 
        public function getQueryInfo() {
+               $dbr = wfGetDB( DB_REPLICA );
                return [
                        'tables' => [ 'page', 'watchlist' ],
                        'fields' => [
@@ -54,7 +55,7 @@ class UnwatchedpagesPage extends QueryPage {
                        'conds' => [
                                'wl_title IS NULL',
                                'page_is_redirect' => 0,
-                               "page_namespace != '" . NS_MEDIAWIKI . "'"
+                               'page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
                        ],
                        'join_conds' => [ 'watchlist' => [
                                'LEFT JOIN', [ 'wl_title = page_title',
index 76b721c..c37ecbd 100644 (file)
@@ -49,6 +49,7 @@ class WantedPagesPage extends WantedQueryPage {
        }
 
        function getQueryInfo() {
+               $dbr = wfGetDB( DB_REPLICA );
                $count = $this->getConfig()->get( 'WantedPagesThreshold' ) - 1;
                $query = [
                        'tables' => [
@@ -63,13 +64,13 @@ class WantedPagesPage extends WantedQueryPage {
                        ],
                        'conds' => [
                                'pg1.page_namespace IS NULL',
-                               "pl_namespace NOT IN ( '" . NS_USER . "', '" . NS_USER_TALK . "' )",
-                               "pg2.page_namespace != '" . NS_MEDIAWIKI . "'"
+                               'pl_namespace NOT IN (' . $dbr->makeList( [ NS_USER, NS_USER_TALK ] ) . ')',
+                               'pg2.page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
                        ],
                        'options' => [
                                'HAVING' => [
-                                       "COUNT(*) > $count",
-                                       "COUNT(*) > SUM(pg2.page_is_redirect)"
+                                       'COUNT(*) > ' . $dbr->addQuotes( $count ),
+                                       'COUNT(*) > SUM(pg2.page_is_redirect)'
                                ],
                                'GROUP BY' => [ 'pl_namespace', 'pl_title' ]
                        ],